package com.huike.web.controller;

import com.github.pagehelper.PageInfo;
import com.huike.entity.Permission;
import com.huike.query.QueryObject;
import com.huike.service.PermissionService;
import com.huike.util.ReturnObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;
    @RequestMapping("/list")
    public String getList(@ModelAttribute("qo")QueryObject qo, Model model){
        PageInfo<Permission> page = permissionService.getPage(qo.getCurrentPage(), qo.getPageSize());
        model.addAttribute("pageInfo",page);
        return "permission/list";
    }
    @ResponseBody
    @RequestMapping("/reload")
    public ReturnObject reload(){
        permissionService.reload();
        return new ReturnObject();
    }
}
